package com.cy.test;

import com.cy.server.Request;
import com.cy.server.Response;
import com.cy.servlet.HttpServlet;
import com.cy.utils.HttpProtocolUtil;

import java.io.IOException;

/**
 * @Author ChenYan
 * @Date 2021/8/13 14:20
 * @Description
 */
public class CyServlet extends HttpServlet {

    @Override
    public void doGet(Request request, Response response) {
        String str = "<h1>Servlet doGet</h1>";
        try {
            response.output(HttpProtocolUtil.getHttpHeader200(str.getBytes().length) + str);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        String str = "<h1>Servlet doPost</h1>";
        try {
            response.output(HttpProtocolUtil.getHttpHeader200(str.getBytes().length) + str);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void init() {

    }

    @Override
    public void destroy() {

    }
}
